﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DesignPatterns
{
    /// <summary>
    /// 支付类  （抽象部分）
    /// </summary>
    public class Pay
    {
        protected IPayMode _padMode;

        public Pay(IPayMode padMode)
        {
            this._padMode = padMode;
        }

        public virtual string Validation(int uId, string uName)
        {
            return "验证情况汇报：" + _padMode.IsControl(uId);
        }
    }

    /// <summary>
    /// 支付宝支付  (具体实现类)
    /// </summary>
    class zfbPay : Pay
    {
        public zfbPay(IPayMode _padMode)
            : base(_padMode)
        {

        }

        public override string Validation(int uId, string uName)
        {
            var isValue = _padMode.IsControl(uId);
            return "支付宝正在进行验证操作 ，" + isValue + "，用户：" + uName;
        }
    }

    /// <summary>
    /// 微信支付  (具体实现类)
    /// </summary>
    class wxPay : Pay
    {
        public wxPay(IPayMode padMode) : base(padMode)
        {

        }

        public override string Validation(int uId, string uName)
        {
            var isValue = _padMode.IsControl(uId);
            return "微信正在进行验证操作：" + isValue + "，用户：" + uName;
        }
    }

    /// <summary>
    /// 支付模式 
    /// 人脸识别、密码识别
    /// </summary>
    public interface IPayMode
    {
        /// <summary>
        /// 是否满足风控要求
        /// </summary>
        /// <param name="uId"></param>
        /// <returns></returns>
        string IsControl(int uId);
    }

    /// <summary>
    /// 人脸识别
    /// </summary>
    public class FaceRecognition : IPayMode
    {
        public string IsControl(int uId)
        {
            return "人脸识别成功，你的ID为 " + uId + "满足风控要求，支付成功。";
        }
    }

    /// <summary>
    /// 账号密码
    /// </summary>
    public class PasswardInput : IPayMode
    {
        public string IsControl(int uId)
        {
            return "密码识别成功，你的ID为 " + uId + "满足风控要求，支付成功。";
        }
    }
}
